﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include "GcmpGuiMainFrame.h"
#include "IUIWelcome.h"
#include <QObject>
#include <vector>
#include <map>

#include "QWidget"

class QAction;
class QMenu;
class QComboBox;

namespace gcmp
{
    class IMainWindow;
}

namespace gcmp
{
    class GCMP_GUI_MAIN_FRAME_EXPORT WelcomeWidget
        : public QWidget
    {
        Q_OBJECT
    public:
        WelcomeWidget(QWidget *parent = 0);
        virtual ~WelcomeWidget(void) {};
        virtual void UpdateUI() {};
    };

    struct WidgetInfo
    {
    public:
        WelcomeWidget* m_widget;
        std::wstring m_name;
    };

    class GCMP_GUI_MAIN_FRAME_EXPORT UIWelcome : public QObject, public IUIWelcome
    {
        Q_OBJECT

    public:
        UIWelcome(IMainWindow* pUIMainWnd);
        virtual ~UIWelcome(void);

    public:

        // 更新相关
        virtual void Show()override;
        virtual void Hide()override;
        virtual void UpdateUI()override;

        void UpdateUI(QResizeEvent *event);
    private:
        // 框架窗口。
        IMainWindow* m_pUIMainWnd;
    };

    class GCMP_GUI_MAIN_FRAME_EXPORT UIWelcomeManager
    {
        std::vector<WidgetInfo> m_upPages;

    private:
        UIWelcomeManager() {};
        void SetQWidget(WelcomeWidget* childWidget, const std::wstring& widgetName);
        //清除QWidget
        void ClearQWidget();

    public:
        ~UIWelcomeManager();
        static UIWelcomeManager* Get();
        // 得到QWidgets
        WelcomeWidget* GetQWidgets(const std::wstring& widgetName);
        WelcomeWidget* GetQWidgets(const int& widgetIndex);
        //创建，用于初始化欢迎界面
        void AddQWidget(WelcomeWidget* childWidget, const std::wstring& widgetName);
        // 得到QWidgets
        int GetQWidgetsCount() const;
    };

}


